<!--
 * @Description: 事件类型
 * @Author: zzj
 * @Date: 2021-09-15 09:17:22
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-15 10:59:36
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件类型</title>
</head>
<body>
    <select id="s1">
        <option value="0">上海</option>
        <option value="1">北京</option>
        <option value="2">南京</option>
    </select>
    <input type="text" value="hello" id="t1"/>

    <div style="width: 200px;height: 200px;background-color: dodgerblue;" id="d1">
        <div style="width: 100px;height: 100px;background-color: red;" id="d2"></div>
    </div>

    <script>
        var d1 = document.getElementById("d1");
        // d1.onmousemove = function(e){  //仅对块有效
        //     console.log(e);  
        // }
        // d1.onmouseenter = function(){  //不冒泡
        //     console.log("移入")
        // }
        // d1.onmouseleave = function(){  //不冒泡
        //     console.log("移出")
        // }
        d1.onmouseover = function(){  //冒泡
            console.log("移入")
        }
        d1.onmouseout = function(){   //冒泡
            console.log("移出")
        }

        var s1 = document.getElementById("s1");
        s1.onchange = function(e){
            console.log(e.target.value)
        }
        var t1 = document.getElementById("t1");
        t1.onselect = function(){
            console.log("选择了某一个值:")
        }
        t1.onblur = function(){
            console.log("失去了焦点:")
        }
        t1.focus();  //自动获取焦点
        t1.onfocus = function(){
            console.log("获得了焦点:")
        }
    </script>
</body>
</html>